package com.chenl.consumer.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ResourceUtils;

import java.io.File;
import java.io.FileNotFoundException;
@Slf4j
public class FileUtils {

    public static File getUploadPath() {
        try {
            File path = new File(ResourceUtils.getURL("resources:").getPath());
            if (!path.exists()) {
                path = new File("");
            }
            File upload = new File(path.getAbsolutePath(), "static/temp/");
            if (!upload.exists()) {
                boolean r = upload.mkdirs();
                if (!r) {
                    log.info("创建临时路径失败。。。");
                    return null;
                }
            }
            return upload;
        } catch (FileNotFoundException e) {
            return null;
        }
    }
}
